#include<stdio.h>
#include<algorithm>
#define M 100005
using namespace std;
int n,m,L,V,at,b[M],f[M],to[M];
struct Node{int l,r;} a[M],c[M];
int t;
inline void solve(){
	at=0;
	scanf("%d%d%d%d",&n,&m,&L,&V);
	for(int i=1,x,v,d;i<=n;++i){
		scanf("%d%d%d",&x,&v,&d);
		if(d>0){
			int l=x+max(0,(V*V-v*v)/(2*d)+1);
			if(l<=L) a[++at]={l,L};
		}else if(d==0){
			if(v>V) a[++at]={x,L};
		}else if(d<0){
			if(v>V){
				int l=min(L,x+(v*v-V*V-2*d-1)/(-2*d)-1);
				a[++at]={x,l};
			}
		}
	}
	for(int i=1;i<=m;++i) scanf("%d",b+i);
	n=at;
	int ct=0;
	for(int i=1;i<=n;++i){
		a[i].l=lower_bound(b+1,b+m+1,a[i].l)-b,
		a[i].r=upper_bound(b+1,b+m+1,a[i].r)-b-1;
	}
	sort(a+1,a+n+1,[](const Node &x,const Node &y){return x.l>y.l;});
	t=0;
	for(int i=1,r=m+1;i<=n;++i) if(a[i].l<=a[i].r){
		++ct;
		if(a[i].r<r) r=a[i].r,c[++t]=a[i];
	}
	for(int i=1;i<=t;++i) a[t-i+1]=c[i];
	n=t,f[0]=0;
	for(int i=1;i<=n;++i) to[i]=lower_bound(a+1,a+i,a[i].l,[](const Node &a,int b){return a.r<b;})-a;
	for(int i=1;i<=n;++i) f[i]=f[to[i-1]]+1;
	int ans=n;
	for(int i=1;i<=n;++i) if(a[i].r>=a[n].l) ans=min(ans,f[i]);
	printf("%d %d\n",ct,m-ans);
}
int main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	int T;scanf("%d",&T);
	while(T--) solve();
}